/**
 * Created by xiongxin on 17/7/26.
 */

angular.module('myApp.services', []).factory('myFactory', ['$http', '$q', function($http, $q) {
        var defer = $q.defer();
        return {
            send: function(url, options, fn, sendType){
                $http({
                    method: 'POST',
                    url: url,
                    data: options,
                    timeout: defer.promise
                }).success(function(data){ 
                    defer.resolve(data);
                    console.log(data);

                    if(fn){
                        fn(data);
                    }

                }).error(function(error){
                    defer.reject(error);
                    console.log('系统异常');
                });

                return defer.promise;
            },

            //企业公告信息
            companyNew: function(fn){
                var url = testUrl+'/app/operator/banner/findBanNanners';
                var option = {
                    type: 2,
                    isBank: 'Y'
                };
                this.send(url, option, fn);
            },
            //查询工作申请类型
            findJobTypes: function (fn) {
                var url = testUrl+'/app/job/findJobTypes';
                var option = null;
                this.send(url, option, fn);
            },
            // 查询有权限的审批人
            findAppUser: function (fn) {
                var url = testUrl+'/app/job/findAppUser';
                var option = {
                    openUserid: 'xion123dd'
                };
                this.send(url, option, fn);
            }
        }
    }]);
